Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
class System.​Buffers.​ArrayPool<​T>
Assembly: System.Runtime
Inheritance: object → ArrayPool
Provides a resource pool that enables reusing instances of type T[].
Properties
public static
ArrayPool<​T>
Shared
Gets a shared <see cref="T:System.Buffers.ArrayPool`1" /> instance.
Methods
public static
ArrayPool<​T>
Create​()
Creates a new instance of the <see cref="T:System.Buffers.ArrayPool`1" /> class.
Returns A new instance of the <see cref="T:System.Buffers.ArrayPool`1" /> class.
public static
ArrayPool<​T>
Create​(int maxArrayLength,
int maxArraysPerBucket)
Creates a new instance of the <see cref="T:System.Buffers.ArrayPool`1" /> class using the specified configuration.
Returns A new instance of the <see cref="T:System.Buffers.ArrayPool`1" /> class with the specified configuration.
maxArrayLength
The maximum length of an array instance that may be stored in the pool.
maxArraysPerBucket
The maximum number of array instances that may be stored in each bucket in the pool. The pool groups arrays of similar lengths into buckets for faster access.
public
T[]
Rent​(int minimumLength)
Retrieves a buffer that is at least the requested length.
Returns An array of type T that is at least <paramref name="minimumLength" /> in length.
minimumLength
The minimum length of the array.
public
void
Return​(T[] array,
bool clearArray = false)
Returns an array to the pool that was previously obtained using the <see cref="M:System.Buffers.ArrayPool`1.Rent(System.Int32)" /> method on the same <see cref="T:System.Buffers.ArrayPool`1" /> instance.
array
A buffer to return to the pool that was previously obtained using the <see cref="M:System.Buffers.ArrayPool`1.Rent(System.Int32)" /> method.
clearArray
Indicates whether the contents of the buffer should be cleared before reuse. If <paramref name="clearArray" /> is set to <see langword="true" /> , and if the pool will store the buffer to enable subsequent reuse, the <see cref="M:System.Buffers.ArrayPool`1.Return(`0[],System.Boolean)" /> method will clear the <paramref name="array" /> of its contents so that a subsequent caller using the <see cref="M:System.Buffers.ArrayPool`1.Rent(System.Int32)" /> method will not see the content of the previous caller. If <paramref name="clearArray" /> is set to <see langword="false" /> or if the pool will release the buffer, the array's contents are left unchanged.
public
bool
Equals​(object obj)
Inherited from object
Determines whether the specified object is equal to the current object.
Returns <see langword="true" /> if the specified object is equal to the current object; otherwise, <see langword="false" /> .
obj
The object to compare with the current object.
protected
void
Finalize​()
Inherited from object
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
public
int
GetHashCode​()
Inherited from object
Serves as the default hash function.
Returns A hash code for the current object.
public
Type
GetType​()
Inherited from object
Gets the <see cref="T:System.Type" /> of the current instance.
Returns The exact runtime type of the current instance.
protected
object
MemberwiseClone​()
Inherited from object
Creates a shallow copy of the current <see cref="T:System.Object" /> .
Returns A shallow copy of the current <see cref="T:System.Object" /> .
public
string
ToString​()
Inherited from object
Returns a string that represents the current object.
Returns A string that represents the current object.